import { loadChannelAPI } from '../../api/channel';
import { CHANNEL_SET_LIST, CHANNEL_SET_CURRENT } from './actionType';

export const getChannelListCreator = () => {
  return async (dispatch) => {
    const { data } = await loadChannelAPI();
    dispatch({ type: CHANNEL_SET_LIST, payload: data.channels });
  };
};

export const setCurrentCreator = (id) => {
  return {
    type: CHANNEL_SET_CURRENT,
    payload: id,
  };
};
